/**
 * 
 */
package com.bagtrack.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;


/**
 * @author Brian Boyle
 * Nov 13, 2011
 *
 */
@Entity
@Table(name = "USER")
public class User {

    private Long id;
    private String firstName;
    private String lastName;
    private String username;
    private String password;
    private String token;
    private String userType;
    private List<Job> jobs;


    /**
     * @param firstName
     * @param lastName
     * @param username
     * @param password
     * @param token
     * @param userType
     */
    public User(String firstName, String lastName, String username, String password, String token, String userType) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.username = username;
        this.password = password;
        this.token = token;
        this.userType = userType;
    }

    /**
     * Default Constructor
     */
    public User() {

    }

    /**
     * Return the user's full name by concatonating the first and last name.
     * @return The user's full name.
     */
    @Transient
    public String getName() {
        return getFirstName() + " " + getLastName();
    }


    /**
     * @return the id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    public Long getId() {
        return id;
    }


    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }


    /**
     * @return the firstName
     */
    @Column(name = "FIRST_NAME")
    public String getFirstName() {
        return firstName;
    }


    /**
     * @param firstName the firstName to set
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }


    /**
     * @return the lastName
     */
    @Column(name = "LAST_NAME")
    public String getLastName() {
        return lastName;
    }


    /**
     * @param lastName the lastName to set
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }


    /**
     * @return the username
     */
    @Column(name = "USERNAME")
    public String getUsername() {
        return username;
    }


    /**
     * @param username the username to set
     */
    public void setUsername(String username) {
        this.username = username;
    }


    /**
     * @return the password
     */
    @Column(name = "PASSWORD")
    public String getPassword() {
        return password;
    }


    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }


    /**
     * @return the token
     */
    @Column(name = "TOKEN")
    public String getToken() {
        return token;
    }


    /**
     * @param token the token to set
     */
    public void setToken(String token) {
        this.token = token;
    }


    /**
     * @return the userType
     */
    @Column(name = "TYPE")
    public String getUserType() {
        return userType;
    }


    /**
     * @param userType the userType to set
     */
    public void setUserType(String userType) {
        this.userType = userType;
    }


    /**
     * @return the jobs
     */
    @OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
    @JsonIgnore
    public List<Job> getJobs() {
        return jobs;
    }


    /**
     * @param jobs the jobs to set
     */
    public void setJobs(List<Job> jobs) {
        this.jobs = jobs;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "User [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", username=" + username + ", password=" + password + ", token=" + token + ", userType=" + userType + "]";
    }
}
